
package com.joysuch.wwyt.datadump.biz.query;

import cn.zlg.common.datadump.condition.QueryCondtionDef;
import cn.zlg.common.datadump.condition.QueryFieldCondition;
import cn.zlg.common.datadump.condition.QueryFieldConditionSet;
import cn.zlg.common.datadump.condition.SortFieldDef;
import com.joysuch.wwyt.mh.entity.dsl.QMhMajorHazard;
import com.joysuch.wwyt.mh.entity.dsl.QMhMonitoringPoint;
import com.joysuch.wwyt.mh.entity.dsl.QMhMonitoringType;
import com.querydsl.core.types.Order;

import java.util.Arrays;
import java.util.List;

public class MhMonitorPointDumpQueryBean implements QueryCondtionDef {

    @Override
    public List<QueryFieldConditionSet> getConditionSet() {
        QMhMonitoringPoint q = QMhMonitoringPoint.mhMonitoringPoint;
        return Arrays.asList(
                QueryFieldConditionSet.Builder().names("name", "nameOrCode").or(
                        new QueryFieldCondition("name", q,
                                q.pointCode, q.id, "contains"),
                        new QueryFieldCondition("name", q,
                                q.name, q.id, "contains")
                ).build(),
                QueryFieldConditionSet.Builder().names("state", "showState").or(
                        new QueryFieldCondition("state", q,
                                q.showState, q.id, "eq"),
                        new QueryFieldCondition("state", q,
                                q.showState, q.id, "isNull")
                ).build()
        );
    }

    @Override
    public QueryFieldCondition[] getAllConditionDef() {
        QMhMonitoringPoint q = QMhMonitoringPoint.mhMonitoringPoint;
        return new QueryFieldCondition[] {
                new QueryFieldCondition("ids", q,
                        q.id, q.id, "in"),

                new QueryFieldCondition("categoryId", QMhMonitoringType.mhMonitoringType,
                        QMhMonitoringType.mhMonitoringType.categoryId, QMhMonitoringType.mhMonitoringType.id,
                        q.mhMonitoringType.id, "eq"),
                new QueryFieldCondition("monitoringTypeId", QMhMonitoringType.mhMonitoringType,
                        QMhMonitoringType.mhMonitoringType.id, QMhMonitoringType.mhMonitoringType.id,
                        q.mhMonitoringType.id, "eq"),
                 };
    }

    @Override
    public SortFieldDef[] getAllSortFieldDef() {
        QMhMonitoringPoint q = QMhMonitoringPoint.mhMonitoringPoint;
        return new SortFieldDef[] {
                new SortFieldDef(q.id, "id", Order.DESC, true) ,
                new SortFieldDef(q.name, "name", Order.ASC)
        };
    }
}
